s=input('введите скобочную последовательность')
s1=0
s2=0
s3=0
s4=0
s5=0
s6=0
s7=0
s8=0
c1=s.count('(')
c2=s.count(')')

c3=s.count('[')
c4=s.count(']')

c5=s.count('{')
c6=s.count('}')

c7=s.count('<')
c8=s.count('>')
for i in s:
    if i=='(':
        s1+=s.index(i)
    if i==')':
        s2+=s.index(i)

for i in s:
    if i=='{':
        s3+=s.index(i)
    if i=='}':
        s4+=s.index(i)
for i in s:
    if i=='[':
        s5+=s.index(i)
    if i=='[':
        s6+=s.index(i)

for i in s:
    if i=='<':
        s7+=s.index(i)
    if i=='>':
        s8+=s.index(i)
        
if c1==c2 and c3==c4 and c5==c6 and c7==c8 \
   and s1<=s2 and s3<=s4 and s5<=s6 and s7<=s8:
    print('True ')
else:
    print('False ')
